Using the CommandBuilder

The following example uses the CommandBuilder to create a SQL statement on the SequeLink Server Sparky on Oracle.

NOTE: This example uses the "emp" sample table (see "Sample Tables for Oracle"). The Oracle database in this example does not require the Database connection string option.

SequeLinkConnection    DBConn; 
DBConn = new SequeLinkConnection("host=norman;Port=19996;User ID=test01;
                                  Password=test01"); 
SequeLinkDataAdapter    myDataAdapter = new SequeLinkDataAdapter(); 
SequeLinkCommand    DBCmd = new SequeLinkCommand("SELECT * FROM EMP",DBConn); 
myDataAdapter.SelectCommand = DBCmd; 
//  Set up the CommandBuilder 
SequeLinkCommandBuilder  
   CommBuild = new SequeLinkCommandBuilder(myDataAdapter); 
DataSet      myDataSet = new DataSet(); 
try  
{ 
    DBConn.Open(); 
    myDataAdapter.Fill(myDataSet); 
    //  Now change the salary of the first employee 
    DataRow     myRow; 
    myRow = myDataSet.Tables["Table"].Rows[0]; 
    myRow["sal"] = 95000; 
    // Tell the DataAdapter to resynch with the Oracle server. 
    // Without the CommandBuilder, this line would fail. 
    myDataAdapter.Update(myDataSet); 
} 
catch (Exception ex)  
{ 
    // Display any exceptions in a messagebox 
    MessageBox.Show (ex.Message); 
} 
//  Close the connection 
DBConn.Close();